package com.mvw.tetrominoes.data {
	
	/**
	 * An abstract representation of Cluster type using specific String values.
	 */
	public class ClusterType {
		
		private var _type:String;
			
		public static const S:ClusterType = new ClusterType("urn:tetrominoes:type:s");
		public static const Z:ClusterType = new ClusterType("urn:tetrominoes:type:z");
		public static const O:ClusterType = new ClusterType("urn:tetrominoes:type:o");
		public static const I:ClusterType = new ClusterType("urn:tetrominoes:type:i");
		public static const L:ClusterType = new ClusterType("urn:tetrominoes:type:l");
		public static const J:ClusterType = new ClusterType("urn:tetrominoes:type:j");
		public static const T:ClusterType = new ClusterType("urn:tetrominoes:type:t");
	
		private static const ALL:Array = [S,Z,O,I,L,J,T];
		
		/**
		 * The constructor defines type as a String.
		 * 
		 * @param type A String representation of ClusterType.
		 */
		public function ClusterType(type:String):void {
			_type = type;
		}
		
		/**
		 * Returns a random ClusterType.
		 * 
		 * @return A random instance of ClusterType.
		 */
		public static function get random():ClusterType {
			var randomNumber:int = Math.round(Math.random()*(ALL.length-1));
			return new ClusterType(ALL[randomNumber]);
		}
		
		/**
		 * Returns a String representation of ClusterType.
		 * 
		 * @return A String representation of ClusterType.
		 */
		public function toString():String {
			return _type;
		}

	}
}